<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function isSame(str1, str2) {
      for (let i = 0; i < str1.length; i++) {
        if (str2.includes(str1[i])) return true;
      }
    }
    var maxProduct = function (words) {
      let res = 0;

      // 两层循环，两两比较
      for (let i = 0; i < words.length; i++) {
        for (let j = i + 1; j < words.length; j++) {
          // 符合条件的话，就进行计算，然后和res比较大小 
          if (isSame(words[i], words[j]) !== true) {
            const _res = words[i].length * words[j].length;
            if (_res > res) res = _res;
          }
        }
      }
      return res;
    };
    console.log(maxProduct(["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]));
  </script>
</body>

</html>